package com.guxingke.typecho4j.util;

/**
 * 根据日期归档的模型
 * 
 * @author guxingke
 */
public class Archive {
	/**
	 * a标签的href
	 */
	private String url;
	/**
	 * a标签显示的内容
	 */
	private String text;

	/**
	 * 根据一个unix时间戳来实例化一个Archive对象
	 * 
	 * @param unixTimestamp
	 */
	public Archive(Long unixTimestamp) {
		this.url = DateUtil.getDateFormatString(unixTimestamp, "Y-M");
		this.text = getTextByUnixTimestamp(unixTimestamp);
	}

	private String getTextByUnixTimestamp(Long unixTimestamp) {
		String s1 = DateUtil.getDateFormatString(unixTimestamp, "Y");
		String s2 = DateUtil.getDateFormatString(unixTimestamp, "M");
		s2 = getMonthStringByMonthNum(s2);
		return s2 + " " + s1;
	}

	private String getMonthStringByMonthNum(String s2) {
		Integer key = Integer.parseInt(s2);
		switch (key) {
		case 1:
			return "January";
		case 2:
			return "February";
		case 3:
			return "March";
		case 4:
			return "April";
		case 5:
			return "May";
		case 6:
			return "June";
		case 7:
			return "July";
		case 8:
			return "August";
		case 9:
			return "September";
		case 10:
			return "October";
		case 11:
			return "November";
		case 12:
			return "December";
		default:
			break;
		}
		return null;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

}
